package com.highspeed.bdk.gateway.socket.analyze.message.gui.resolver;

import com.highspeed.bdk.gateway.Util;
import com.highspeed.bdk.gateway.socket.analyze.message.gui.base.MessageResolver;

import java.util.HashMap;
import java.util.Map;

/**
 * 3.7 板卡信息查询的反馈包
 * typedef struct _boardFbData
 * {
 * U16 boardId;
 * U16 boardModel;
 * U16 boardSize;
 * U16 boardSN;
 * U16 boardType;
 * U8   resvd: 6,
 * boardStatus: 2; //0 主,1备
 * U8   boardUseStatus;//p
 * char boardName[32];
 * } BoardFbData;
 */
public class BoardFbDataResolver0x01 extends MessageResolver {

    @Override
    protected Map doResolveBody(byte[] response) {
        Map result = new HashMap();

        short boardId = Util.getShort(response, getOffset());
        offset2();
        logger.info("boardId ................" + boardId);
        result.put("boardId", boardId);
        result.put("slotNum", ((boardId >> 2) & 63));
        result.put("machineBoxNo", boardId & 3);
        result.put("boardName", boardId);

        short boardModel = Util.getShort(response, getOffset());
        offset2();
        logger.info("boardModel..........." + boardModel);
        result.put("boardModel", boardModel);

        short boardSize = Util.getShort(response, getOffset());
        offset2();
        logger.info("boardSize..........." + boardSize);
        result.put("boardSize", boardSize);

        short boardSN = Util.getShort(response, getOffset());
        offset2();
        logger.info("boardSN..........." + boardSN);
        result.put("boardSN", boardSN);

        short boardType = Util.getShort(response, getOffset());
        offset2();
        logger.info("boardType..........." + boardType);
        result.put("boardType", boardType);

        byte u8 = Util.getByte(response, getOffset());
        offset1();
        logger.info("u8..........." + u8);
        result.put("u8", u8);

        byte boardUseStatus = Util.getByte(response, getOffset());
        offset1();
        logger.info("boardUseStatus..........." + boardUseStatus);
        result.put("boardUseStatus", boardUseStatus);

//            byte[] boardNameByte = new byte[32];b
//            System.arraycopy(response, offset, boardNameByte, 0, 32);
//            offset += 32;
//            boardFbData.setBoardName(oardName);
        put("board", result);
        return getContainer();
    }

}
